<html ng-app="modalTest">

<head>
    <!-- Bootstrap Core CSS -->
    <link href="/megaacerto/style/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js"></script>
    <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js" type="text/javascript"></script>
    <script src="http://m-e-conroy.github.io/angular-dialog-service/javascripts/dialogs.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        angular
        					.module('modalTest', [ 'ui.bootstrap', 'dialogs' ])
        					.controller(
        							'dialogServiceTest',
        							function($scope, $rootScope, $dialogs) {
        								$scope.carregar = function(idJogo){
        									var jogos = [{
        										id:"1",
        										jogo:"02 03 05 07 10 12"
        									},
        									{
        										id:"2",
        										jogo:"01 03 06 08 09 12"
        									},
        									{
        										id:"3",
        										jogo:"05 07 09 11 15 18"
        									},
        									{
        										id:"4",
        										jogo:"03 05 07 09 12 16"
        									},
        									{
        										id:"05",
        										jogo:"06 07 08 18 22 28"
        									},
        									{
        										id:"06",
        										jogo:"02 04 06 07 10 11"
        									}];
        									var tabela = "";
        									$scope.valor = "oi";
        									for(i = 0; i < jogos.length; i++){
        										tabela += '<tr><th></th><th>'+jogos[i].id+'</th><th>'+jogos[i].jogo+''+'</th><tr/>'
        									}
        									alert(tabela);
        									//alert(idJogo);
        									dlg = $dialogs.create(
        										'/modal/carregarJogos.html',
        										'modalDinamico', {}, {
        											key : false,
        											back : 'static'
        										});
        								}
        							})
        					// end dialogsServiceTest
        					.controller(
        							'modalDinamico',
        							function($scope, $modalInstance, data) {
        								$scope.user = {
        									name : ''
        								};
        								$scope.cancel = function() {
        									$modalInstance.dismiss('canceled');
        								}; // end cancel
        								$scope.save = function() {
        									$modalInstance.close($scope.user.name);
        								}; // end save
        								$scope.hitEnter = function(evt) {
        									if (angular.equals(evt.keyCode, 13)
        											&& !(angular.equals($scope.name, null) || angular
        													.equals($scope.name, '')))
        										$scope.save();
        								}; // end hitEnter
        							})
        					// end whatsYourNameCtrl
        					.run(
        							[
        									'$templateCache',
        									function($templateCache) {
        										$templateCache
        												.put(
        														'/modal/carregarJogos.html',
        														'<div class="modal">'+
        															'<div class="modal-dialog">'+
        																'<div class="modal-content">'+
        																	'<div class="modal-header"><h4 class="modal-title"><span class="glyphicon glyphicon-star"></span> Modal din�mico</h4></div>'+
        																	'<div class="modal-body">'+
        																		'<label ng-model="valor">Oi,{{valor}}</label>'+
        																		'<table class="table table-striped table-hover "><thead><tr><th></th><th>ID</th><th>Jogo</th></tr></thead>'+
        																		//TABELA
        																	'</table>'+
        																'</div>'+
        																'<div class="modal-footer"><button type="button" class="btn btn-default" ng-click="cancel()">Cancelar</button><button type="button" class="btn btn-primary" ng-click="save()" ng-disabled="(nameDialog.$dirty && nameDialog.$invalid) || nameDialog.$pristine">Salvar</button></div></div></div></div>');
        											} ]); // end run / module
    </script>
    <style type="text/css">
        /* Fix for Bootstrap 3 with Angular UI Bootstrap */
        				.modal {
        					display: block;
        				}
        				/* Custom dialog/modal headers */
        				.dialog-header-error {
        					background-color: #d2322d;
        				}
        				.dialog-header-wait {
        					background-color: #428bca;
        				}
        				.dialog-header-notify {
        					background-color: #eeeeee;
        				}
        				.dialog-header-confirm {
        					background-color: #333333;
        				}
        				.dialog-header-error span,.dialog-header-error h4,.dialog-header-wait span,.dialog-header-wait h4,.dialog-header-confirm span,.dialog-header-confirm h4
        					{
        					color: #ffffff;
        				}
        				/* Ease Display */
        				.pad {
        					padding: 25px;
        				}
    </style>
</head>

<body ng-controller="dialogServiceTest" class="pad">
    <h2>Teste do Daniel Souza</h2>
    <br />
    <div class="row">
        <div class="col-md-12">
            <button class="btn btn-warning" ng-click="carregar('12')">Criar</button>
        </div>
    </div>
    <br />
</body>

</html>